﻿<%@ Assembly Name="JM.JCY.SharePointComponent, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a3f76d78e78426e2" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"
    Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register TagPrefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages"
    Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="AlbumHomeUserControl.ascx.cs"
    Inherits="JM.JCY.SharePointComponent.PhotoAlbum.AlbumHome.AlbumHomeUserControl" %>
<script type="text/javascript">
    $(document).ready(function () {
        $("#toggleAlbum1").click(function () {
            var div = document.getElementById("divToggleAlbum");
            if (div.style.display == "") {
                div.style.display = "none";
                $("#imgToggleAlbum").attr("src", "/_layouts/JM.JCY.Resource/images/toggle_expand.png");
            }
            else {
                div.style.display = "";
                $("#imgToggleAlbum").attr("src", "/_layouts/JM.JCY.Resource/images/toggle_collapse.png");
            }
        });

        $("#toggleAlbum2").click(function () {
            var div = document.getElementById("divToggleAlbum");
            if (div.style.display == "") {
                div.style.display = "none";
                $("#imgToggleAlbum").attr("src", "/_layouts/JM.JCY.Resource/images/toggle_expand.png");
            }
            else {
                div.style.display = "";
                $("#imgToggleAlbum").attr("src", "/_layouts/JM.JCY.Resource/images/toggle_collapse.png");
            }
        });
    });

    function RedirectToViewAlbum(sender, albumId) {
        sender.href = "/PhotoAlbumPages/ViewAlbum.aspx?AlbumId=" + albumId;
    }

    function RedirectToStaffProfile(sender, staffId) {
        sender.href = "/PersonalSite/PersonalPages/PublicUser.aspx?StaffId=" + staffId;
        return false;
    }

    function ResizeImage(sender) {
        var image = new Image();
        image.src = sender.src;
        if (image.width > 0 && image.height > 0) {
            var height = image.height;
            var width = image.width;
            if (parseInt(width) / parseInt(height) >= 90 / 70) {
                sender.style.height = 70;
            }
        }
    }
</script>
<style type="text/css">
    #background
    {
        z-index: -1;
        border: 1px solid #B8B8B8;
        width: 94px;
        height: 74px;
        margin-bottom: 10px;
    }
    #imagebox
    {
        z-index: 1;
        border: 1px solid #B8B8B8;
        margin-left: 2px;
        margin-top: 2px;
        width: 90px;
        height: 70px;
        background-color: #ffffff;
        padding: 2px;
    }
    #containerImg
    {
        width: 90px;
        height: 70px;
        padding: 0px;
        overflow: hidden;
        float: none;
    }
</style>
<div>
    <table class="main" width="300px" cellpadding="0" cellspacing="0" border="0">
        <tr>
            <td>
                <table class="webpart" width="100%" cellpadding="0" cellspacing="0">
                    <tr>
                        <th id="toggleAlbum1" style="cursor: pointer" class="top" align="left" width="50%" align="left">
                            <asp:Image ID="Image1" runat="server" ImageUrl="/_layouts/JM.JCY.Resource/images/相册小.png"
                                Width="24" />
                            相册
                        </th>
                        <th id="toggleAlbum2" style="cursor: pointer" class="link" align="right" width="50%">
                            <img class="toggle" id="imgToggleAlbum" src="/_layouts/JM.JCY.Resource/images/toggle_collapse.png" />
                        </th>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <div id="divToggleAlbum">
                                <table width="100%" class="webpartContent" cellpadding="0" cellspacing="0" border="0">
                                    <tr>
                                        <td height="6px">
                                        </td>
                                    </tr>
                                    <tr>
                                        <th align="left">
                                            <asp:Label ID="Label2" runat="server" Text="&nbsp;&nbsp;&nbsp;&nbsp;最近更新的相册"></asp:Label>
                                        </th>
                                    </tr>
                                    <tr>
                                        <td >
                                            <asp:DataList ID="dlRecentUpdate" runat="server" RepeatColumns="2" OnItemDataBound="DataList_ItemDataBound">
                                                <ItemTemplate>
                                                    <div>
                                                        <table class="webpartContent">
                                                            <tr>
                                                                <td>
                                                                    <div id="background">
                                                                        <div id="imagebox">
                                                                            <div id="containerImg">
                                                                                <a id="img" href="#" class="link" onclick="RedirectToViewAlbum(this,'<%# Eval("AlbumId") %>')">
                                                                                    <img id="imgThumbNail" src='<%# Eval("ThumbNailImgUrl") %>' width="90" alt='<%# Eval("Description") %>'
                                                                                        onload="ResizeImage(this);" />
                                                                                </a>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                </td>
                                                                <td>
                                                                    &nbsp;&nbsp;&nbsp;
                                                                </td>
                                                                <td>
                                                                    <table>
                                                                        <tr>
                                                                            <td>
                                                                                <asp:LinkButton ID="lbAlbumName" CssClass="link" runat="server" Text='<%# PartSubString("AlbumName",Eval("Name").ToString()) %>'
                                                                                    OnClientClick='<%# String.Format("RedirectToViewAlbum({0},{1})","this",Eval("AlbumId")) %>'
                                                                                    ToolTip='<%# Eval("Name") %>'></asp:LinkButton>
                                                                            </td>
                                                                        </tr>
                                                                        <tr>
                                                                            <td>
                                                                                <asp:Label ID="lblBy" runat="server" CssClass="gallery" Text="创建人："></asp:Label>
                                                                                <asp:LinkButton ID="lbCreateBy" runat="server" CssClass="link" Text='<%# PartSubString("AlbumOwner",Eval("AlbumOwner").ToString()) %>'
                                                                                    ToolTip='<%# Eval("AlbumOwner") %>' OnClientClick='<%# String.Format("RedirectToStaffProfile({0},{1})","this",Eval("Creator")) %>'></asp:LinkButton>
                                                                            </td>
                                                                        </tr>
                                                                        <tr runat="server" id="trDetail">
                                                                            <td>
                                                                                <asp:Label ID="lblMediaCount" CssClass="gallery" runat="server" Text='<%# Eval("ItemCount") %>'></asp:Label>
                                                                                <asp:Label ID="lblMedia" CssClass="gallery" runat="server" Text="照片"></asp:Label>
                                                                                <asp:Image ID="imgLike" runat="server" ImageUrl="/_layouts/JM.JCY.Resource/images/thumbs-up.gif" />
                                                                                <asp:Label ID="lblLikeCount" CssClass="gallery" runat="server" Text='<%# Eval("LikeCount") %>'></asp:Label>
                                                                            </td>
                                                                        </tr>
                                                                    </table>
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </div>
                                                </ItemTemplate>
                                            </asp:DataList>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <br />
                                            <hr />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="right" valign="middle">
                                            <asp:LinkButton ID="lbViewAllAlbum" runat="server" OnClick="lbViewAllAlbum_Click">更多...</asp:LinkButton>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</div>
